package com.itheima.homework.assignment.Test01;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

/**
 * 有四名学生参加注册会计师考试,表格中记录的是4名学生的考试成绩,
 * 请按照成绩将四名学生从小到大进行排名,并将结果展示出来
 */
public class Test {
    public static void main(String[] args) {
        ArrayList<Student> students = new ArrayList<>();

        students.add(new Student(1, "小亮", 99));
        students.add(new Student(2, "小勇", 85));
        students.add(new Student(3, "小响", 90));
        students.add(new Student(4, "小强", 89));

        Collections.sort(students, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return Double.compare(o1.getScore(), o2.getScore());
            }
        });

        System.out.println("students = " + students);
    }
}
